<?php use_helper('OpenSocial'); ?>

//----------------------------------------------------------------------------
//
// OpenSocial.Gadget.ActivityStream class
//
//----------------------------------------------------------------------------

OpenSocial.Gadget.ActivityStream = Class.create();

OpenSocial.Gadget.ActivityStream.prototype = {
  postActivityStream: function(title, body, priority, callback) {
    if (typeof(priority) == 'undefined' || priority == null)
      priority = opensocial.CreateActivityPriority.LOW;

    var params = {};
    params[opensocial.Activity.Field.TITLE] = title;
    params[opensocial.Activity.Field.BODY]  = body;
    
    var activity = opensocial.newActivity(params);
    opensocial.requestCreateActivity(activity, priority, cb);
  }
};

<script type="text/javascript">
<?php if($onLoad): ?>
  <?php echo registerOnLoadHandler($onLoad); ?>
<?php endif; ?>

function pending(content_div,msg)
{
  document.getElementById(content_div).innerHTML = '<img title="pending" src="http://sghdc.no-ip.org/opensocial/images/indicator.gif"/><small> '+msg+'</small>';
}

function adjustHeight() 
{
  if (typeof(gadgets) != 'undefined' && typeof(gadgets.window) != 'undefined' && typeof(gadgets.window.adjustHeight) != 'undefined')
    gadgets.window.adjustHeight();
  else if (typeof(_IG_AdjustIFrameHeight) != "undefined")
    _IG_AdjustIFrameHeight();
};

function postActivity(text) 
{ 
  var params = {};  
  params[opensocial.Activity.Field.TITLE] = text;
  var activity = opensocial.newActivity(params); 
  opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, postActivityCallback);
};        
  
function postActivityCallback(data) {
  //var title = data.getField(opensocial.Activity.Field.TITLE);
  //title = gadgets.util.unescapeString(title);
  //document.getElementById('status_div').innerHTML = title;
};

</script>




//----------------------------------------------------------------------------
// Begin _IG_ specific code        

OpenSocial.Gadget.registerOnloadHandler = function(onloadHandler) {
  if (typeof(_IG_RegisterOnloadHandler) != "undefined")
    _IG_RegisterOnloadHandler(onloadHandler);
  else
    setTimeout(onloadHandler, 1);
};

OpenSocial.Gadget.adjustHeight = function() {
  if (typeof(gadgets) != 'undefined' && typeof(gadgets.window) != 'undefined' && typeof(gadgets.window.adjustHeight) != 'undefined')
    gadgets.window.adjustHeight();
  else if (typeof(_IG_AdjustIFrameHeight) != "undefined")
    _IG_AdjustIFrameHeight();
};

